authApp.value('page','material_makeschool'); 
authApp.controller("bsDataController",function($scope,$http,$cookies,$getQueryString){
	if($getQueryString("isfill")=="2"){
		$scope.schoolId=$getQueryString("schoolId");
		$scope.isHideAction=true;
	}
	
	$scope.isAddZYC=true;
	$scope.isAddZYP=true;
	$scope.savaInfo=function(type){
		var confirmHtml="是否保存";
		if(type=="sub"){
			confirmHtml="是否提交";
		}
		if(window.confirm(confirmHtml)){
			var methodUrl=apis.insertschoolRunning1;
			var methodStatus="0";
			var alertMsg="保存成功";
			if($getQueryString("isfill")=="1"){
				methodUrl=apis.updateSchoolRunning1;
			}else if($getQueryString("isfill")=="0"){
				methodUrl=apis.insertschoolRunning1;
			}else{
				$scope.isHideAction=true;
			}
			if(type=="su"){
				methodStatus="0";
				alertMsg="保存成功";
			}else if(type=="sub"){
				methodStatus="1";
				alertMsg="提交成功";
			}
			/*if(!$scope.schoolStartTime||$scope.schoolStartTime.length<6){
				alert("请输入正确的时间");
				return
			}
			if(!$scope.reorganizationTime||$scope.reorganizationTime.length<6){
				alert("请输入正确的时间");
				return
			}
			if(!$scope.schoolUpgradedCollegeTime||$scope.schoolUpgradedCollegeTime.length<6){
				alert("请输入正确的时间");
				return
			}
			if(!$scope.undergraduateSchoolTime||$scope.undergraduateSchoolTime.length<6){
				alert("请输入正确的时间");
				return
			}
			if(!$scope.undergraduateProfessionalStartTime||$scope.undergraduateProfessionalStartTime.length<6){
				alert("请输入正确的时间");
				return
			}
			if(!$scope.specialtyStartupTime||$scope.specialtyStartupTime.length<6){
				alert("请输入正确的时间");
				return
			}*/
			var GZTArray=$scope.GZT.split(",");
			var SZTArray=$scope.SZT.split(",");
			var planType="";
			angular.forEach(GZTArray,function(i,index){
				if(index==(GZTArray.length-1)){
					planType+="0";
				}else{
					planType+="0,";
				}
			})
			planType+=",";
			angular.forEach(SZTArray,function(i,index){
				if(index==(SZTArray.length-1)){
					planType+="1";
				}else{
					planType+="1,";
				}
			})
			$http({
				method:'post',
				url:methodUrl,
				data:{
					'status':methodStatus,
					'schoolStartTime':$scope.schoolStartTime,
					'reorganizationTime':$scope.reorganizationTime,
					'schoolUpgradedCollegeTime':$scope.schoolUpgradedCollegeTime,
					'undergraduateSchoolTime':$scope.undergraduateSchoolTime,
					'undergraduateProfessionalStartTime':$scope.undergraduateProfessionalStartTime,
					'specialtyStartupTime':$scope.specialtyStartupTime,
					'planType':planType,
					'planTime':$scope.GZT+","+$scope.SZT,
					'remark1':$scope.remark1,
					'remark2':$scope.remark2,
					'remark3':$scope.remark3,
					'remark4':$scope.remark4,
					'remark5':$scope.remark5,
					'remark6':$scope.remark6,
					'remark7':$scope.remark7,
					'remark8':$scope.remark8,
				},
			}).success(function(response){
				if(response.code=="000000"){
					alert(alertMsg);
					location.href="../datafill.html";
				}
				$scope.judeAllList=response.data;
			})
		}
	}
	$scope.showAddC=function(){
		$scope.isAddZYC=false;
		$scope.isAddZYP=true;
	}
	$scope.showAddP=function(){
		$scope.isAddZYC=true;
		$scope.isAddZYP=false;
	}
	$scope.hideAddC=function(){
		$scope.isAddZYC=true;
		$scope.addZYCValue="";
	}
	$scope.hideAddP=function(){
		$scope.isAddZYP=true;
		$scope.addZYPValue="";
	}
	$scope.addCZYValue=function(){
		if(!$scope.addZYCValue){
			alert("请输入正确的时间");
		}else{
			if(!$scope.GZT){
				$scope.GZT=$scope.addZYCValue;
			}else{
				$scope.GZT+=","+$scope.addZYCValue;
			}
			$scope.isAddZYC=true;
			$scope.addZYCValue="";
		}
	}
	$scope.addSZYValue=function(){
		if(!$scope.SZT){
			$scope.SZT=$scope.addZYPValue;
		}else{
			$scope.SZT+=","+$scope.addZYPValue;
		}
		$scope.isAddZYP=true;
		$scope.addZYPValue="";
	}
	$scope.getInfo=function(){
		$http({
			method:'get',
			url:apis.querySchoolRunningBySchoolId2,
			params:{'schoolid':$scope.schoolId},
		}).success(function(response){
			if(response.code=="000000"){
				$scope.schoolStartTime=response.data.authSchoolRunningData.schoolStartTime;
				$scope.reorganizationTime=response.data.authSchoolRunningData.reorganizationTime;
				$scope.undergraduateSchoolTime=response.data.authSchoolRunningData.undergraduateSchoolTime;
				$scope.schoolUpgradedCollegeTime=response.data.authSchoolRunningData.schoolUpgradedCollegeTime;
				$scope.undergraduateProfessionalStartTime=response.data.authSchoolRunningData.undergraduateProfessionalStartTime;
				$scope.specialtyStartupTime=response.data.authSchoolRunningData.specialtyStartupTime;
				$scope.GZT=response.data.countryPlanTime;
				$scope.SZT=response.data.provincePlanTime;
				$scope.remark1=response.data.authSchoolRunningData.remark.split("#")[0];
				$scope.remark2=response.data.authSchoolRunningData.remark.split("#")[1];
				$scope.remark3=response.data.authSchoolRunningData.remark.split("#")[2];
				$scope.remark4=response.data.authSchoolRunningData.remark.split("#")[3];
				$scope.remark5=response.data.authSchoolRunningData.remark.split("#")[4];
				$scope.remark6=response.data.authSchoolRunningData.remark.split("#")[5];
				$scope.remark7=response.data.authSchoolRunningData.remark.split("#")[6];
				$scope.remark8=response.data.authSchoolRunningData.remark.split("#")[7];
			}
			$scope.judeAllList=response.data;
		})
	}
	if($getQueryString("isfill")=="1"||$getQueryString("isfill")=="2"){
		$scope.getInfo();
	}
})
